<?php
include("../includes/common.php");
$title = '小程序广告配置';
include './head.php';
if ($islogin == 1) {
} else exit("<script language='javascript'>window.location.href='./login.php';</script>");
$my = isset($_GET['my']) ? $_GET['my'] : null;
$banner = $DB -> get_row("select * from auth_gg where `k`='banner'");
$cp = $DB -> get_row("select * from auth_gg where `k`='cp'");
$gz= $DB -> get_row("select * from auth_gg where `k`='gz'");
$jili = $DB -> get_row("select * from auth_gg where `k`='jili'");
$ys = $DB -> get_row("select * from auth_gg where `k`='ys'");
?>
<div class="container" style="padding-top:70px;">
    <div class="col-xs-12 col-sm-10 col-lg-8 center-block" style="float: none;">
            <?php
            if($my == 'update'){
                $banner  = isset($_POST['banner'])?daddslashes($_POST['banner']):null;
                $cp  = isset($_POST['cp'])?daddslashes($_POST['cp']):null;
                $gz  = isset($_POST['gz'])?daddslashes($_POST['gz']):null;
                $jili = isset($_POST['jili'])?daddslashes($_POST['jili']):null;
                $ys  = isset($_POST['ys'])?daddslashes($_POST['ys']):null;
                
                $res1 = $DB -> query("update auth_gg set `v`='{$banner}' where `k`='banner'");
                $res2 = $DB -> query("update auth_gg set `v`='{$cp}' where `k`='cp'");
                $res4 = $DB -> query("update auth_gg set `v`='{$gz}' where `k`='gz'");
                $res5 = $DB -> query("update auth_gg set `v`='{$jili}' where `k`='jili'");
                $res6 = $DB -> query("update auth_gg set `v`='{$ys}' where `k`='ys'");

                if ($res1&&$res2&&$res4&&$res5&&$res6){
                    showmsg('修改成功！<br/><br/><a href="./config.php">>>返回</a>', 1);
                }else{
                    showmsg('修改失败！' . $DB->error(), 4);
                }

            }else{?>
        <div class="panel panel-primary">
                <div class="panel-heading"style="background:#000000; color:#FFFFFF"><h3 class="panel-title">小程序广告</h3></div>
                <div class="panel-body">
                    <form action="./config.php?my=update" method="POST" enctype="multipart/form-data">
                        <div class="form-group">
                        <label>banner广告ID：</label><br>
                        <textarea name="banner" id="" cols="15" rows="1" style="max-width: 100%;width:100%"><?php echo $banner['v'] ?></textarea>
                        <label>激励式广告ID：</label><br>
                        <textarea  name="jili" id="" cols="15" rows="1" style="max-width: 100%;width:100%"><?php echo $jili['v'] ?></textarea>
                        <label>插屏广告ID：</label><br>
                        <textarea name="cp" id="" cols="15" rows="1" style="max-width: 100%;width:100%"><?php echo $cp['v'] ?></textarea>
                        <label>格子广告ID：</label><br>
                        <textarea name="gz" id="" cols="15" rows="1" style="max-width: 100%;width:100%"><?php echo $gz['v'] ?>
                        </textarea>
                        <label>原生模板广告ID：</label></br>
                        <textarea name="ys" id="" cols="15" rows="1" style="max-width: 100%;width:100%"><?php echo $ys['v'] ?></textarea>
                        <input type="submit" class="btn btn-primary btn-block" value="保存" style="background:#000000; color:#FFFFFF">
                    </form>
                    <br/><a href="./index.php">>>返回首页</a>
                </div>
        </div>


            <?php }
            ?>


    </div>
</div>